<?php
namespace app\admin\service;

use app\admin\model\BoxMediaOrderLog;

/**
 * 媒体管理-服务类
 */
class BoxOrderMediaLogService extends BaseService
{
    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->model = new BoxMediaOrderLog();
    }

    /**
     * Desc : 获取数据列表
     * User : you name
     * Date : 2024-04-08 15:03
     * @return array
     */
    public function getList(): array
    {
        $param = request()->param();
        // 查询条件
        $map = [];

        $pay_status = isset($param['pay_status']) ? (int)$param['pay_status'] : 0;
        if ($pay_status) {
            $map[] = ['pay_status', '=', $pay_status];
        }
        if(isset($param['member_id']) && !empty($param['member_id'])){
            $map[] = ['member_id','=',$param['member_id']];
        }
        if(isset($param['member_account']) && !empty($param['member_account'])){
            $map[] = ['member_account','=',$param['member_account']];
        }
        if(isset($param['package_id']) && !empty($param['package_id'])){
            $map[] = ['package_id','=',$param['package_id']];
        }
        if(isset($param['promote_id']) && !empty($param['promote_id'])){
            $map[] = ['promote_id','=',$param['promote_id']];
        }
        if(isset($param['game_role_id']) && !empty($param['game_role_id'])){
            $map[] = ['game_role_id','=',$param['game_role_id']];
        }
        if(isset($param['game_role_name']) && !empty($param['game_role_name'])){
            $map[] = ['game_role_name','like','%'.$param['game_role_name'].'%'];
        }
        if(isset($param['pay_way']) && !empty($param['pay_way'])){
            $map[] = ['pay_way','=',$param['pay_way']];
        }
        if(isset($param['pay_game_status']) && !empty($param['pay_game_status'])){
            $map[] = ['pay_game_status','=',$param['pay_game_status']];
        }
        if(isset($param['pay_time']) && !empty($param['pay_time'])){
            $map[] = ['pay_time','between time',$param['pay_time']];
        }
        if(isset($param['pay_order_number']) && !empty($param['pay_order_number'])){
            $map[] = ['pay_order_number','=',$param['pay_order_number']];
        }

        $list = $this->model->where($map)->order('id', 'desc')->page(PAGE, PERPAGE)->select();
        //获取数据总数
        $count = $this->model->where($map)->count();

        //返回结果
        return  array(
            "msg"   => '操作成功',
            "code"  => 0,
            "data"  => $list,
            "count" => $count,
        );
    }

}
